package com.scau402.system1.domain.factory;

import com.scau402.system1.domain.dto.WmsOutboundOrderDTO;
import com.scau402.system1.domain.po.WmsAuditOrderPO;
import com.scau402.system1.domain.po.WmsOutboundOrderDO;
import com.scau402.system1.domain.vo.WmsOutboundOrderVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * 出库的工厂
 */
@Component
public class WmsOutboundOrderFactory {

    public WmsOutboundOrderDO toWmsOutboundOrderDO(WmsOutboundOrderDTO wmsOutboundOrderDTO) {
        return Optional.ofNullable(wmsOutboundOrderDTO)
                .map(x -> {
                    WmsOutboundOrderDO wmsOutboundOrderDO = new WmsOutboundOrderDO();
                    BeanUtils.copyProperties(x, wmsOutboundOrderDO);
                    return wmsOutboundOrderDO;
                })
                .orElse(null);
    }

    public WmsOutboundOrderVO toWmsOutboundOrderVo(WmsOutboundOrderDO wmsOutboundOrderDO) {
       return Optional.ofNullable(wmsOutboundOrderDO)
               .map(x -> {
                   WmsOutboundOrderVO wmsOutboundOrderVO = new WmsOutboundOrderVO();
                   BeanUtils.copyProperties(x, wmsOutboundOrderVO);
                   return wmsOutboundOrderVO;
               })
               .orElse(null);
    }
}
